Skip to content

feat(#109): -verify matcher for hash verification - #428

Merged
helly25 merged 1 commit into
mainfrom
feature/109-verify-matcher
Aug 9, 2026
Merged

feat(#109): -verify matcher for hash verification#428
helly25 merged 1 commit into
mainfrom
feature/109-verify-matcher

Conversation

@helly25

@helly25 helly25 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Adds the -verify EXPECTED matcher (#109) - the manifest-verification companion of -hash.

What

-verify EXPECTED is a predicate: true when the file's computed digest equals EXPECTED, a {field} template rendered per entry.

xff . -type f -verify {def.SUMS}     # files that match their expected digest
xff . -type f ! -verify {def.SUMS}   # drift / corruption
  • Expected hash comes from the field vocabulary (a {def.X} value, a {capture.X}, or a literal), so no bespoke manifest parser is needed - a sidecar-manifest reader can later just populate {def.X}.
  • -verify=ALGO[/ENCODING] shares the -hash spec grammar (sha256/hex default; sha1/sha512/md5, hex/base64).
  • Hex comparison folds case (sha256sum lowercases, SRI-style tools upper-case); base64 stays case-sensitive by definition.
  • Style::kXff, so the find style rejects it; a bad spec is a pre-walk usage error (exit 2).

How

Wiring mirrors -cmp (arity-1 field-template target) + -hash (Binding::kHash). The parser's kHash =SPEC branch now consumes the descriptor's arity operands (previously hard-coded arity 0), so -verify=sha256 EXPECTED parses; ValidateHashArgs covers -verify too.

Test

  • xff/cli/verify_test.sh: match/mismatch, {def.X} source, hex case-fold, ALGO/ENCODING selectors, ! -verify drift, bad-spec + find-style usage errors.
  • bazel test //xff/... --config=clang: 89 pass. clang-tidy clean; XFF.md regenerated.

Follow-up slice (tracked in TODO #109): --summary tallies of verified vs failed and --summary=hash dedup grouping.

Add the `-verify EXPECTED` predicate: TRUE when the file's computed digest
equals EXPECTED, a {field} template rendered per entry - the manifest-
verification companion of -hash. So:

  xff . -type f -verify {def.SUMS}      # list files matching their manifest
  xff . -type f ! -verify {def.SUMS}    # list drift / corruption

`-verify=ALGO[/ENCODING]` shares the -hash spec grammar (sha256/hex default;
sha1/sha512/md5, hex/base64); hex comparison folds case (sha256sum lowercases,
SRI-style tools upper-case) while base64 stays case-sensitive. Style::kXff, so
the find style rejects it; a bad spec is a pre-walk usage error.

Wiring mirrors -cmp (arity-1 field-template target) + -hash (kHash binding);
the parser's kHash =SPEC branch now consumes the descriptor's arity operands
so `-verify=sha256 EXPECTED` parses. ValidateHashArgs covers -verify too.

Tests: xff/cli/verify_test.sh (match/mismatch, {def.X} source, hex case-fold,
ALGO/ENCODING selectors, `! -verify` drift, bad-spec + find-style errors).
Regenerated XFF.md; CHANGELOG + TODO updated. --summary tallies deferred to a
follow-up slice.
@helly25
helly25 enabled auto-merge (squash) August 9, 2026 21:24
@helly25
helly25 disabled auto-merge August 9, 2026 21:26
@helly25
helly25 merged commit 0f0fba5 into main Aug 9, 2026
10 checks passed
@helly25
helly25 deleted the feature/109-verify-matcher branch August 9, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant